<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\OrderComment;

class OrderCommentEntity extends ABaseEntity
{
    public function __construct(OrderComment $model)
    {
        $this->model = $model;
    }

    public function getId(): int
    {
        return (int) $this->model->id;
    }

    public function setId(int $id): void
    {
        $this->model->id = $id;
    }

    public function getOrderId(): int
    {
        return (int) $this->model->order_id;
    }

    public function setOrderId(int $order_id): void
    {
        $this->model->order_id = $order_id;
    }

    public function getOaGid(): string
    {
        return (string) $this->model->oa_gid;
    }

    public function setOaGid(string $oa_gid): void
    {
        $this->model->oa_gid = $oa_gid;
    }

    /**
     * @return string
     */
    public function getContent()
    {
        return (string) $this->model->content;
    }

    public function setContent(string $content): void
    {
        $this->model->content = $content;
    }

    public function getSyncStatus(): int
    {
        return (int) $this->model->sync_status;
    }

    public function setSyncStatus(int $sync_status): void
    {
        $this->model->sync_status = $sync_status;
    }

    public function getCreatedAt(): string
    {
        return (string) $this->model->created_at;
    }

    public function setCreatedAt(string $created_at): void
    {
        $this->model->created_at = $created_at;
    }

    /**
     * 订单是否存在评价
     *
     * @return bool
     */
    public function isComment(int $orderId)
    {
        $id = parent::getOriginalModel()->where('order_id', $orderId)->get(['id'])->first();

        return (bool) $id;
    }

    public function getStarNum(): int
    {
        return (int) $this->model->star_num;
    }

    public function setStarNum(int $star_num): void
    {
        $this->model->star_num = $star_num;
    }
}
